package jianzhiOffer;

public class num22 {
    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode cur = head;
        for(int i = 0;i < k;i ++) {
            cur = cur.next;
        }
        ListNode prev = head;
        while(cur != null) {
            prev = prev.next;
            cur = cur.next;
        }
        return prev;
    }
}
